package com.hzj.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzj.pojo.Person;
import com.hzj.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hzj
 * @since 2021-03-10
 */
@RestController
//@RequestMapping("/person")

public class PersonController {
    @Autowired
    PersonService ps;

    @RequestMapping("/show")
    public Page show(int index, int size) {
//        System.out.println("进分页");
        Page page = ps.selectPage(index, size);
//        System.out.println(page);
        return page;
    }

    @PostMapping("/add")
    public int add(Person person) {
        return ps.add(person);
    }

    @PostMapping("/update")
    public int update(Person person) {
//        System.out.println(person);
        return ps.update(person);
    }

    @GetMapping("/delete")
    public int delete(int id) {
        return ps.delete(id);
    }

    @GetMapping("/check")
    public Person check(int id) {
        return ps.showPerson(id);
    }
}

